package ioc

import (
	"github.com/ecodeclub/ekit/set"
	"github.com/prometheus/client_golang/prometheus/promhttp"
	"go-admin/server/internal/global"
	"net/http"
)

// InitOther 初始化不在 wire_gen 里面的代码
func InitOther() {
	InitViper()
	initPrometheus()
	initPublicPaths()
}
func initPrometheus() {
	go func() {
		http.Handle("/metrics", promhttp.Handler())
		http.ListenAndServe(":8083", nil)
	}()
}

func initPublicPaths() {
	global.PublicPaths = set.NewMapSet[string](9)

	global.PublicPaths.Add("/users/login")
	global.PublicPaths.Add("/users/signup")
	global.PublicPaths.Add("/users/login/sms")
	global.PublicPaths.Add("/oauth2/wechat/authurl")
	global.PublicPaths.Add("/oauth2/wechat/callback")
	global.PublicPaths.Add("/users/sms")
	global.PublicPaths.Add("/admin/login")
	global.PublicPaths.Add("/health")
	global.PublicPaths.Add("/metrics")
	global.PublicPaths.Add("/test/metric")
}
